class Attribute(object):
    def __init__(self, name):
        self.name = name

    def create_targets(self, value, defender):
        targets = []
        for i in range(0, value):
            targets.append(self)
        return targets

    def handle_loss(self, unit):
        unit.attributes[self] -= 1

    def count(self, value):
        return value

    def supply_needed_to_move(self, value):
        return value

    def __str__(self):
        return self.name

class Empty(Attribute):
    def handle_loss(self, unit):
        pass

    def count(self, value):
        return 0

    def supply_needed_to_move(self, value):
        return 0


class FirePower(Attribute):
    pass

class Protection(Attribute):
    def create_targets(self, value, defender):
        targets = []
        for i in range(0, value):
            targets.append(self)
            targets.append(EMPTY)
            if defender:
                targets.append(EMPTY)
        return targets

class Mobility(Attribute):
    def create_targets(self, value, defender):
        targets = []
        for i in range(0, value):
            targets.append(self)
            if not defender:
                targets.append(EMPTY)
        return targets

class ActionPoints(Attribute):
    def create_targets(self, value, defender):
        return []
    
    def handle_loss(self, unit):
        raise NotImplementedError("We should not get here")

    def supply_needed_to_move(self, value):
        return 0

    def count(self, value):
        return 0

class Defence(Attribute):
    def create_targets(self, value, defender):
        targets = []
        for i in range(0, value):
            if defender:
                targets.append(self)
        return targets

    def supply_needed_to_move(self, value):
        return 0

class Supply(Attribute):
    pass

class Victory(Attribute):
    pass

ACTIONPOINTS = ActionPoints("ActionPoints")
DEFENCE = Defence("Defence")
EMPTY = Empty("Empty")
FIREPOWER = FirePower("FirePower")
MOBILITY = Mobility("Mobility")
PROTECTION = Protection("Protection")
SUPPLY = Supply("Supply")
VICTORY = Victory("Victory")

